package rsee.com;
import com.video.h264.GlobalUtil;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RelativeLayout;


public class LoadActivity extends Activity
{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
		this.setContentView(R.layout.load);
		
		Button playButton = (Button)findViewById(R.id.button1);
		playButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,padUiActivity.class);
				intent.putExtra("comefrom",GlobalUtil.fromLoad);
				startActivity(intent);
			}
			});
		RelativeLayout layout1 = (RelativeLayout)findViewById(R.id.layout1);
		if(padUiActivity.add)
			layout1.setVisibility(View.GONE);
		
		Button addButton = (Button)findViewById(R.id.button2);
		addButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				//Settings();
				 intoList();
			}
			});
		
		Button setButton = (Button)findViewById(R.id.button3);
		setButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,KeySetting.class);
				startActivity(intent);
			}
			});
				
		Button aboutButton = (Button)findViewById(R.id.button4);
		aboutButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,Image.class);
				startActivity(intent);
			}
			});
		
		
		Button helpButton = (Button)findViewById(R.id.button8);
		helpButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,SysLocalSettingPage.class);
				startActivity(intent);
			}
			});
		
		
		Button SyssettingButton = (Button)findViewById(R.id.sys_btn);
		SyssettingButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,SysLocalSettingPage.class);
				startActivity(intent);
			}
			});
	
		Button aalrmButton = (Button) findViewById(R.id.button5);
		aalrmButton.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(LoadActivity.this,PushActivity.class);
				startActivity(intent);
			}
			});
		
		
//		Button downfileButton =  (Button) findViewById(R.id.button7);
//		downfileButton.setOnClickListener(new Button.OnClickListener(){
//			public void onClick(View v) {
//				Intent intent = new Intent(LoadActivity.this,SearchPage.class);
//				startActivity(intent);
//			}
//			});
		
	}
	
    @Override
	protected void onResume() {
        super.onResume();
		if(GlobalUtil.OVSIAlarmConfig){
			ActivityList activityList = new ActivityList();
			activityList.put(this, 0);
			}
    }
    
    @Override
	protected void onDestroy() {
        super.onDestroy();
		if(GlobalUtil.OVSIAlarmConfig){
			ActivityList activityList = new ActivityList();
			activityList.remove(this);
			}
    }
	
//    @SuppressWarnings("unused")
//	private void Settings(){
//    	Intent intent = new Intent (this,newSettings.class);
//    	startActivityForResult(intent, 1);
//    }
    
    private void intoList()
    {
    	Intent intent = new Intent (this,ListActivity.class);
    	intent.putExtra("comefrom", GlobalUtil.fromLoad);
		startActivity(intent);
    }
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(!padUiActivity.add){
		if(keyCode == KeyEvent.KEYCODE_BACK)
		{
			new AlertDialog.Builder(this)
				.setTitle(R.string.IDS_Out)
				.setPositiveButton(R.string.IDS_Btn_OK, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						//android.os.Process.killProcess(android.os.Process.myPid());
						finish();
					}
				})
				.setNegativeButton(R.string.IDS_Btn_Quit, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
					}
				})
				.show();
			return true;
		}
		return true;
		}
		return super.onKeyDown(keyCode, event);
	}
		 
}